package com.baobao.dao;

import com.baobao.domain.Chat;

import java.util.Calendar;
import java.util.Set;

import org.skyway.spring.util.dao.JpaDao;
import org.springframework.dao.DataAccessException;

/**
 * DAO to manage Chat entities.
 * 
 */
public interface ChatDAO extends JpaDao<Chat> {

	/**
	 * JPQL Query - findChatByTextContaining
	 *
	 */
	public Set<Chat> findChatByTextContaining(String text) throws DataAccessException;

	/**
	 * JPQL Query - findChatByTextContaining
	 *
	 */
	public Set<Chat> findChatByTextContaining(String text, int startResult, int maxRows) throws DataAccessException;

	/**
	 * JPQL Query - findChatByReceiverContaining
	 *
	 */
	public Set<Chat> findChatByReceiverContaining(String receiver) throws DataAccessException;

	/**
	 * JPQL Query - findChatByReceiverContaining
	 *
	 */
	public Set<Chat> findChatByReceiverContaining(String receiver, int startResult, int maxRows) throws DataAccessException;

	/**
	 * JPQL Query - findChatByReceiver
	 *
	 */
	public Set<Chat> findChatByReceiver(String receiver_1) throws DataAccessException;

	/**
	 * JPQL Query - findChatByReceiver
	 *
	 */
	public Set<Chat> findChatByReceiver(String receiver_1, int startResult, int maxRows) throws DataAccessException;

	/**
	 * JPQL Query - findChatByStatusContaining
	 *
	 */
	public Set<Chat> findChatByStatusContaining(String status) throws DataAccessException;

	/**
	 * JPQL Query - findChatByStatusContaining
	 *
	 */
	public Set<Chat> findChatByStatusContaining(String status, int startResult, int maxRows) throws DataAccessException;

	/**
	 * JPQL Query - findChatByText
	 *
	 */
	public Set<Chat> findChatByText(String text_1) throws DataAccessException;

	/**
	 * JPQL Query - findChatByText
	 *
	 */
	public Set<Chat> findChatByText(String text_1, int startResult, int maxRows) throws DataAccessException;

	/**
	 * JPQL Query - findChatByDate
	 *
	 */
	public Set<Chat> findChatByDate(java.util.Calendar date) throws DataAccessException;

	/**
	 * JPQL Query - findChatByDate
	 *
	 */
	public Set<Chat> findChatByDate(Calendar date, int startResult, int maxRows) throws DataAccessException;

	/**
	 * JPQL Query - findChatByStatus
	 *
	 */
	public Set<Chat> findChatByStatus(String status_1) throws DataAccessException;

	/**
	 * JPQL Query - findChatByStatus
	 *
	 */
	public Set<Chat> findChatByStatus(String status_1, int startResult, int maxRows) throws DataAccessException;
	
	/**
	 * JPQL Query - findChatByPhoneAndStatus
	 *
	 */
	public Set<Chat> findChatByPhoneAndStatus(String sender, String receiver, String status) throws DataAccessException;
	
	/**
	 * 读取最新N条群组消息
	 * @param receiver
	 * @param msgnum
	 * @return
	 * @throws DataAccessException
	 */
	public Set<Chat> findChatByReceiverAndLatestMsgnum( String receiver,Calendar startDate, Integer msgnum) throws DataAccessException;
	
	/**
	 * JPQL Query - findChatByPhoneAndStatus
	 *
	 */
	public Set<Chat> findChatByPhoneAndStatus(String sender, String receiver, String status, int startResult, int maxRows) throws DataAccessException;

	/**
	 * JPQL Query - findChatByPrimaryKey
	 *
	 */
	public Chat findChatByPrimaryKey(String sender, String receiver_2, java.util.Calendar date_1) throws DataAccessException;
	
	//查找sender发送给receiver的最大日期（最后）的消息记录
	public Set<Chat> findChatByMaxDateAndPhone(String sender,String receiver) throws DataAccessException;

	/**
	 * JPQL Query - findChatByPrimaryKey
	 *
	 */
	public Chat findChatByPrimaryKey(String sender, String receiver_2, Calendar date_1, int startResult, int maxRows) throws DataAccessException;

	/**
	 * JPQL Query - findChatBySenderContaining
	 *
	 */
	public Set<Chat> findChatBySenderContaining(String sender_1) throws DataAccessException;

	/**
	 * JPQL Query - findChatBySenderContaining
	 *
	 */
	public Set<Chat> findChatBySenderContaining(String sender_1, int startResult, int maxRows) throws DataAccessException;

	/**
	 * JPQL Query - findChatByUniqueId
	 *
	 */
	public Set<Chat> findChatByUniqueId(Integer uniqueId) throws DataAccessException;

	/**
	 * JPQL Query - findChatByUniqueId
	 *
	 */
	public Set<Chat> findChatByUniqueId(Integer uniqueId, int startResult, int maxRows) throws DataAccessException;

	/**
	 * JPQL Query - findAllChats
	 *
	 */
	public Set<Chat> findAllChats() throws DataAccessException;

	/**
	 * JPQL Query - findAllChats
	 *
	 */
	public Set<Chat> findAllChats(int startResult, int maxRows) throws DataAccessException;

	/**
	 * JPQL Query - findChatBySender
	 *
	 */
	public Set<Chat> findChatBySender(String sender_2) throws DataAccessException;

	/**
	 * JPQL Query - findChatBySender
	 *
	 */
	public Set<Chat> findChatBySender(String sender_2, int startResult, int maxRows) throws DataAccessException;

}